$(function(){
	var flag = 0;
	var fla = 0;
	var loginName ;
	var loginpassword ;
	$("#loginName").bind({
		focus:function(){
			var a = $(this).val();
			a = a.trim();
			if(a!="请输入登陆的用户名"){
				$(this).css("color","black");
			}else{
				$(this).val('');
				$(this).css("color","black");
			}
		},
		blur:function(){
			var b = $(this).val();
			b = b.trim();
			if(b==""){
				$(this).val("请输入登陆的用户名");
				$(this).css("color","gray");
			}
			//js验证用户名
			var re = /^[0-9a-zA-Z\u4e00-\u9fa5_]{0,15}$/;
		    if(re.test(b)){
		        $("#errorname").css("visibility","hidden");
		        flag = 0;
		        loginName = b;
		    }else{
		    	$("#errorname").css("visibility","visible");
		    	flag = 1;
		    }
		}
	});
	$("#loginPwd").bind({
		focus:function(){
			var c = $(this).val();
			c = c.trim();
			if(c==""){
				$(this).attr("type","text");
				$(this).val("请输入您的登陆密码");
			}else{
				if(c=="请输入您的登陆密码"){
					$(this).val("");
					$(this).attr("type","password");
					$(this).css("color","black");
				}else{
					$(this).attr("type","password");
					$(this).css("color","black");
				}
			}
		},
		blur:function(){
			var d = $(this).val();
			d = d.trim();
			if(d==""){
				$(this).attr("type","text");
				$(this).val("请输入您的登陆密码");
				$(this).css("color","gray");
			}
			var regStr = /^([A-Z]|[a-z]|[0-9]){6,10}$/;
			if(regStr.test(d)){
				$("#errorpwd").css("visibility","hidden");
				fla = 0;
				loginpassword = d;
			}else{
				$("#errorpwd").css("visibility","visible");
				fla = 1;
			}
		}
	});
	$("#sub").click(function(){
		if(flag==0 && fla==0 && loginName!=null){
			$("#loginform").submit();
		}else{
			$("#returnError").css("display","block");
		}
	});
	$(document).keyup(function(event){
		  if(event.keyCode ==13){
			  $("#sub").click();
		  }
	});
});



